import { createRouter, createWebHistory } from 'vue-router'
import Home from '@/views/Home/Home.vue'
import Category from '@/views/Category/Category.vue'
import Login from '@/views/Login/Login.vue'
import Layout from '@/views/Layout/Layout.vue'
import SubCategory from '@/views/SubCategory/index.vue'
import Detail from '@/views/Detail/index.vue'
import Cartlist from '@/views/CartList/index.vue'
import CheckOut from '@/views/CheckOut/index.vue'
import Pay from '@/views/Pay/index.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: Layout,
      children: [
        {
          path: '',
          name: 'home',
          component: Home,
        },
        {
          path: 'category/:id',
          name: 'category',
          component: Category,
        },
        {
          path: 'category/subcategory/:id',
          name: 'subcategory',
          component: SubCategory,
        },
        {
          path: 'detail/:id',
          name: 'detail',
          component: Detail,
        },
        {
          path: 'cartlist',
          name: 'cartlist',
          component: Cartlist,
        },
        {
          path: 'checkout',
          name: 'checkout',
          component: CheckOut,
        },
        {
          path: 'pay',
          name: 'pay',
          component: Pay,
        },
      ],
    },
    {
      path: '/login',
      component: Login,
    },

    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
  ],
  scrollBehavior() {
    return {
      top: 0,
    }
  },
})

export default router
